﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
                
>
  <xsl:output method="html" media-type="text/html" encoding="utf-8" />
  <xsl:param name="relrootpath"/>
  <xsl:template match="/GroupRequestContext">
    <xsl:variable name="ranum" select="generate-id(.)" />

    <Transform>

      <ContentToRender>
        <Template status="Pending">
          <Scripts>
            <Block name="scu-grouprequest">
              <script>
                function approvegrouprequest(requestid)
                {
                
                $.ajax({ type: 'POST',
                contentType: 'application/json',
                url: relRootPath + '/Mod/Groups/GroupWebService.asmx/ApproveJoinRequest',
                data: "{ 'rid': '" + requestid + "' }",
                dataType: 'json',
                async: true,
                success: function(result)
                {
                location.reload();
                },
                error: function(result, status) {
                $(this).attr('disabled', false);
                }
                }
                );

                }

                function rejectgrouprequest(requestid)
                {
                $.ajax({ type: 'POST',
                contentType: 'application/json',
                url: relRootPath + '/Mod/Groups/GroupWebService.asmx/RejectJoinRequest',
                data: "{ 'requestId': '" + requestid + "' }",
                async: true,
                dataType: 'json',
                success: function(result)
                {
                location.reload();
                },
                error: function(result, status) {
                $(this).attr('disabled', false);
                }
                });
                }


                google.setOnLoadCallback(function()
                {
                $('.approvebutton').click(function(){

                approvegrouprequest($(this).attr('rel'));
                disableactionbutton();
                });

                $('.rejectbutton').click(function(){

                rejectgrouprequest($(this).attr('rel'));
                disableactionbutton();
                });

                function disableactionbutton()
                {
                $('.actionbutton').attr('disabled', true).unbind('click');
                }

                });
              </script>
            </Block>
          </Scripts>
          <Content>
            <div class="fc lpmatchresult">
              <div>
                <control kind="userlink">
                  <xsl:attribute name="UserId">
                    <xsl:value-of select="RequestorUserId"/>
                  </xsl:attribute>
                </control>
                <xsl:text>请求参加活动</xsl:text>
                <a>
                  <xsl:attribute name="href">
                    <xsl:value-of select="$relrootpath"/>
                    <xsl:text>/Mod/Groups/ViewGroup.aspx?id=</xsl:text>
                    <xsl:value-of select="EventId"/>
                  </xsl:attribute>
                  <xsl:value-of select="EventName"/>
                </a>
                <xsl:text>。</xsl:text>
              </div>
              <div class="ctn-p-t">
                <a class="approvebutton pointer actionbutton">
                  <xsl:attribute name="rel">
                    <xsl:value-of select="RequestId"/>
                  </xsl:attribute>
                  同意请求
                </a>
                |
                <a class="rejectbutton pointer actionbutton">
                  <xsl:attribute name="rel">
                    <xsl:value-of select="RequestId"/>
                  </xsl:attribute>
                  拒绝请求
                </a>
              </div>
            </div>
          </Content>
        </Template>
        <Template status="Approved">
          <Content>
            <div>
              <strong>圈子请求</strong>
              <div>
                <control kind="userlink">
                  <xsl:attribute name="UserId">
                    <xsl:value-of select="RequestorUserId"/>
                  </xsl:attribute>
                </control>
                <xsl:text>请求加入圈子</xsl:text>
                <a>
                  <xsl:attribute name="href">
                    <xsl:value-of select="$relrootpath"/>
                    <xsl:text>/Mod/Groups/ViewGroup.aspx?id=</xsl:text>
                    <xsl:value-of select="GroupId"/>
                  </xsl:attribute>
                  <xsl:value-of select="GroupName"/>
                </a>
                <xsl:text>。</xsl:text>
              </div>
              <div class="ctn-p-t">
                "<xsl:value-of select="Comment"/>"
              </div>
              <div class="hltext right">
                <div class="nss ns-approved">
                  <xsl:text> </xsl:text>
                </div>
                <span class="iconlabel">
                  <xsl:text>你已经同意请求，</xsl:text>
                <control kind="userlink">
                  <xsl:attribute name="UserId">
                    <xsl:value-of select="RequestorUserId"/>
                  </xsl:attribute>
                </control>
                <xsl:text>现在已经是圈子成员。</xsl:text>
                </span>
              </div>
            </div>

          </Content>
        </Template>
        <Template status="Rejected">
          <Content>
            <div>
              <strong>圈子请求</strong>
              <div>
                <control kind="userlink">
                  <xsl:attribute name="UserId">
                    <xsl:value-of select="RequestorUserId"/>
                  </xsl:attribute>
                </control>
                <xsl:text>请求加入圈子</xsl:text>
                <a>
                  <xsl:attribute name="href">
                    <xsl:value-of select="$relrootpath"/>
                    <xsl:text>/Mod/Groups/ViewGroup.aspx?id=</xsl:text>
                    <xsl:value-of select="GroupId"/>
                  </xsl:attribute>
                  <xsl:value-of select="GroupName"/>
                </a>
                <xsl:text>。</xsl:text>
              </div>
              <div class="ctn-p-t">
                "<xsl:value-of select="Comment"/>"
              </div>
              <div class="hltext right">
                <div class="nss ns-ball-red">
                  <xsl:text> </xsl:text>
                </div>
                <span class="iconlabel">你已拒绝了对方的请求。</span>
              </div>
            </div>
          </Content>
        </Template>
      </ContentToRender>
      <ActionList>
        <Template status="Pending">
          <action webservicepath="" webmethod="" text="同意请求">
            <param name="requestid"></param>
          </action>
        </Template>
        <Template status="Rejected">

        </Template>
      </ActionList>
    </Transform>
  </xsl:template>
</xsl:stylesheet>
